//
//  ChangeController.m
//  CMJWeibo
//
//  Created by BH on 15/12/10.
//
//

#import "ChangeController.h"
#import "CMJTabbarController.h"
#import "NewFeatureController.h"

@implementation ChangeController

+(void)chooseRootViewController
{
    // 当前软件的版本号
    NSString *key = (__bridge NSString *)kCFBundleVersionKey;
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
    
    //获取当前主窗口
    UIApplication *application = [UIApplication sharedApplication];
    UIWindow *window = application.keyWindow;
    
    //获取沙盒版本号
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *sandboxVersion = [defaults stringForKey:key];
    
    //比较当前版本号与沙盒中的版本号
    if ([currentVersion compare:sandboxVersion] == NSOrderedDescending) {
        //存储当前版本号
        [defaults setObject:currentVersion forKey:key];
        [defaults synchronize];
        
        window.rootViewController = [[NewFeatureController alloc] init];
    }else{
        //显示状态栏
        application.statusBarHidden = NO;
        
        window.rootViewController = [[CMJTabbarController alloc] init];
    }
}

@end
